﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Kategori : System.Web.UI.Page
{
    protected void Page_PreRender(object sender, EventArgs e)
    {
        DilDegistir();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Sessions.SiparisFiyati = null;
            DataAccess.GetLookUp();
            ddlRenk.RenkDoldur();
            ddlDesen.DesenDoldur();
            ddlDeriCesidi.DeriCesidiDoldur();
            ddlCantaCesidi.CantaTuruDoldur();            
        }

    }

    protected void DilDegistir()
    {

        if (Cookies.Dil == "TR")
        {
            lblBayanCanta.Text = "BAYAN ÇANTA";
            lblErkekCanta.Text = "ERKEK ÇANTA";
            lblSectiklerimiz.Text = "Sizin İçin Seçtiklerimiz";
            lblSiralama.Text=  "Sıralama";
            lblUcuzPahali.Text = "Ucuzdan Pahalıya";
            lblPahaliUcuz.Text = "Pahalıdan Ucuza";
            lblZiyaret.Text = "Ziyaret sayısına göre";
            lblDeriCesidi.Text = "Deri Çeşidi";
            lblDesen.Text = "Desen Seçiniz";
            lblRenk.Text = "Renk Seçiniz";
            lblCantaTuru.Text = "Çanta Türü";
            lblFiyat.Text = "Fiyat";
            
            ddlSiralama.Items[0].Text = "Sıralama";          
            ddlSiralama.Items[1].Text = "Ucuzdan Pahalıya";  
            ddlSiralama.Items[2].Text = "Pahalıdan Ucuza";
            ddlSiralama.Items[3].Text = "Ziyaret sayısına göre";

            //ddlSiralama.Items.Clear();
            //ddlSiralama.Items.Add("Sıralama");
            //ddlSiralama.Items.Add("Ucuzdan Pahalıya");
            //ddlSiralama.Items.Add("Pahalıdan Ucuza");
            //ddlSiralama.Items.Add("Ziyaret sayısına göre");

            //ddlSiralama.Items[0].Value = "-1";
            //ddlSiralama.Items[1].Value = "1";
            //ddlSiralama.Items[2].Value = "2";
            //ddlSiralama.Items[3].Value = "3";
        }
        else
        {
            lblBayanCanta.Text = "WOMEN BAG";
            lblErkekCanta.Text = "MEN BAG";
            lblSectiklerimiz.Text = "Special For You";
            lblSiralama.Text = "Order By";
            lblUcuzPahali.Text = "Cheap to Expensive";
            lblPahaliUcuz.Text = "Expensive to Cheap";
            lblZiyaret.Text = "Visited count";
            lblDeriCesidi.Text = "Skin Type";
            lblDesen.Text = "Select Pattern";
            lblRenk.Text = "Select Colour";
            lblCantaTuru.Text = "Bag Type";
            lblFiyat.Text = "Price";

            //ddlSiralama.Items.Clear();
            ddlSiralama.Items[0].Text = "Order By";             //.Add("Order By");
            ddlSiralama.Items[1].Text = "Cheap to Expensive";   //.Add("Cheap to Expensive");
            ddlSiralama.Items[2].Text = "Expensive to Cheap";   //.Add("Expensive to Cheap");
            ddlSiralama.Items[3].Text = "Visited count";        //.Add("Visited count");

            //ddlSiralama.Items[0].Value = "-1";
            //ddlSiralama.Items[1].Value = "1";
            //ddlSiralama.Items[2].Value = "2";
            //ddlSiralama.Items[3].Value = "3";
        }
    }

    protected void btnHelper_Click(object sender, EventArgs e)
    {
        if (Sessions.UyeId > 0)
        {
            string sr = hidUrunId.Value;
            int UrunId = Convert.ToInt16(sr);

            int BegeniAdedi = DataAccess.UrunBegen(UrunId);
            Sessions.BegeniAdedi = BegeniAdedi;

            (this.Master as Skala).BegeniGuncelle(BegeniAdedi);
            listCanta.DataBind();

        }
        else
            Response.Redirect(Page.GetRouteUrl("UyeGiris", new object { }));
    }
    
    protected void btnCantayaEkle_Click(object sender, EventArgs e)
    {
        if (Sessions.UyeId > 0)
        {
            string CantaDurumu = hidCantaDurumu.Value;
            string sr = hidUrunId.Value;
            int UrunId = Convert.ToInt16(sr);
            int SepetAdedi;

            if (CantaDurumu == "cantayaEkle")
            {
                DataRow drSepet = DataAccess.CantayaEkle(UrunId, 1);
                SepetAdedi = Convert.ToInt16(drSepet["SepetAdedi"]);
                Sessions.SepetAdedi = SepetAdedi;
            }
            else 
            {
                SepetAdedi = DataAccess.CantadanCikar(UrunId);
                Sessions.SepetAdedi = SepetAdedi;
            }
            listCanta.DataBind();
            (this.Master as Skala).SepetAdediGuncelle(SepetAdedi);
        }
        else
            Response.Redirect(Page.GetRouteUrl("UyeGiris", new object { }));
    }
}